package com.shanghaiyimu.yimiyangche.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shanghaiyimu.yimiyangche.R;
import com.shanghaiyimu.yimiyangche.bean.GoodsBean;

import java.util.List;

/**
 * Author:ShangHaiYiMu
 * Time:2017/7/15   10:19
 * Description:GaiZhuangLVAdapter
 */

public class GaiZhuangLVAdapter extends BaseAdapter {

    private Context context;
    private List<GoodsBean> datas;

    public GaiZhuangLVAdapter(Context context, List<GoodsBean> datas) {
        this.context = context;
        this.datas = datas;
    }

    @Override
    public int getCount() {
        return datas!=null?datas.size():0;
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.gaizhuang_item,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.content.setText(datas.get(position).getContent());
        holder.price.setText(datas.get(position).getName());
        return convertView;
    }
    static class ViewHolder{

        private TextView content,price;

        public ViewHolder(View view) {
            content = (TextView) view.findViewById(R.id.content_gaizhuang_item);
            price = (TextView) view.findViewById(R.id.price_gaizhuang_item);
        }
    }
 }
